home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / System 7.0 Samples / INIT - CDEV / INIT - CDEV.make < prev    next >
Encoding:
Text File  |  1994-11-18  |  9.4 KB  |  227 lines  |  [TEXT/MPS ]

  1. #------------------------------------------------------------------------------
  2. #
  3. #    Macintosh Developer Technical Support
  4. #
  5. #    Sample Control Panel Device and INIT Combination
  6. #
  7. #    Program:    INIT - CDEV
  8. #    File:        INIT - CDEV.make    -    Make Source
  9. #
  10. #    Copyright © 1990 Apple Computer, Inc.
  11. #    All rights reserved.
  12. #
  13. #------------------------------------------------------------------------------
  14.  
  15. AppName            =    'INIT - CDEV'
  16. Signature        =    'INCD'
  17.  
  18.  
  19. #------------------------------------------------------------------------------
  20. #
  21. # Options for our compilers:
  22. #
  23. #    -sym on:
  24. #        tells the compilers and linker to emit symbol information for
  25. #        a source level debugger, such as SADE.
  26. #
  27. #    -case on:
  28. #        tells the assembler to treat case differences in symbols as being
  29. #        siginificant. We turn this on because we are dealing with C source
  30. #        as well, which is also case-sensitive. If we were compiling with
  31. #        Pascal, we'd probably turn case off so that we could reference
  32. #        Pascal symbols without having to upper-case them all (which is how
  33. #        Pascal exports its symbols).
  34. #
  35. #    -r:
  36. #        Tells the C compiler to require function prototypes. If it encounters
  37. #        a function definition without first having seen a prototype for
  38. #        it, it will mark it as an error.
  39. #
  40. #    -b:
  41. #        Tells the C compiler to embed literal strings in the C code. Normally,
  42. #        string constants are stored in the global variables space and
  43. #        references off of A5. Since are writing standalone code that
  44. #        doesn't normally have an A5 globals space, we embed the strings into
  45. #        the code and reference it off of  the PC. There are ways of using
  46. #        globals in standalone code, and we use them in the INIT part of
  47. #        our show, but we don't in the CDEV, so we embed them.
  48. #
  49. #    -mbg off:
  50. #        tells the compilers to not emit low-level debugger names. This
  51. #        saves on file space, but you may wish to remove this option if you
  52. #        need to debug with something like Macsbug.
  53. #
  54. #    -append:
  55. #        means to add the resources to the target file, rather than
  56. #        deleting all the ones that are there first.
  57. #
  58. #    -msg nowarn:
  59. #        Tells the Linker to not print any warning messages. When we link
  60. #        our INIT and CDEV we link them with the same list of MPW libraries.
  61. #        However, both the INIT and CDEV need a different set of libraries,
  62. #        so we define the list of libraries to be the union of the needs of
  63. #        the INIT and CDEV. This means that when we link, the linker will
  64. #        tell us we are linking with some unnecessary libraries. Because we
  65. #        don't care about those warnings, we turn them off with this option.
  66. #
  67. #    -rt xxxx=####:
  68. #        This tells the Linker what resource type to create. Normally, it puts
  69. #        its output into CODE resources. Here, we tell it to put it into a
  70. #        cdev=-4064 resource or an INIT=0 resource.
  71. #
  72. #    -m <Procedure Name>:
  73. #        This tells the Linker what the main entry point of our program is. If
  74. #        you are using Pascal, this is normally the routine whose "END"
  75. #        statement is followed by a period. If we are using C, then a main
  76. #        routine is provided for us ("CMain" in CRuntime.o if using MPW 3.1,
  77. #        or "%__Main" in Runtime.o if using MPW 3.2). However, when building
  78. #        stand-alone code, we don't want to use those main procedures; they are
  79. #        for applications only. Therefore, we provide our own entry point for
  80. #        the Linker explicitly. When the Linker does its dead-code stripping, it
  81. #        starts with this routine and does a treewalk. For applications, the
  82. #        main entry point is given jump table location #1 so that the segment
  83. #        loader can find it. Also note that the routine's name needs to be
  84. #        all uppercased for Pascal routines.
  85. #
  86. #    -sg <Segment Name>:
  87. #        MPW only supports single segment standalone code. This means that
  88. #        all of your executable code must belong to one segment. The easiest
  89. #        way to make sure that all of your routines and libraries that they
  90. #        use are put into one segment is to use the -sg <Segment Name> option.
  91. #        Normally, you would say something like -sg <Segment Name>=<list of
  92. #        segments>, which would merge those segments in the list into a single
  93. #        segment with the name <Segment Name>. However, if you omit the list
  94. #        of segments, ALL of your procedures will get put into <Segment Name>.
  95. #
  96. #    -ra <Segment Name> = <attributes>:
  97. #        Sets the resource attributes for the named resource. When INITs are
  98. #        executed, they aren't locked by INIT 31. Because our INIT allocates
  99. #        memory when installing its patch, we must make sure we are locked 
  100. #        down. If not, the code that is executing could be moved out from 
  101. #        under the PC.
  102. #
  103. #------------------------------------------------------------------------------
  104.  
  105. SymOptions        =    #-sym on                    # turn this on to debug with SADE
  106.  
  107. AOptions        =    -case on {SymOptions}
  108. COptions        =    -r -b -mbg off -d SystemSevenOrLater=1 {SymOptions}
  109. RezOptions        =    -append
  110. LinkOptions        =    -msg nowarn {SymOptions}
  111. CDEVLinkOptions    =    {LinkOptions} -rt cdev=-4064 -m TEXTCDEV -sg theCDEV
  112. INITLinkOptions    =    {LinkOptions} -rt INIT=0 -m INITInstall -sg theINIT ∂
  113.                     -ra theINIT=resLocked
  114.  
  115. #------------------------------------------------------------------------------
  116. # These are modified default build rules.  This is necessary to take into
  117. # account differences between MPW 3.1 and 3.2. The normal make rules include
  118. # everything below except that they don't have an {xAltOptions} variable.
  119. # We've added those variables to pass in flags that allow the source code
  120. # to use the appropriate symbols and definitions for the version of MPW
  121. # it's running under. We also add some snazzy echo statements that report
  122. # our progress.
  123. #------------------------------------------------------------------------------
  124.  
  125. .a.o            ƒ    .a
  126.     Echo "    Assembling:    {Default}.a"
  127.     {Asm} {DepDir}{Default}.a -o {TargDir}{Default}.a.o {AOptions}
  128.  
  129. .c.o            ƒ    .c
  130.     Echo "    Compiling:    {Default}.c"
  131.     {C} {DepDir}{Default}.c -o {TargDir}{Default}.c.o {COptions}
  132.  
  133.  
  134. #------------------------------------------------------------------------------
  135. # These are the lists of objects that our sample creates. They are used in
  136. # dependency statements and link commands. Note that in the case of
  137. # INITObjects, the order of the objects is important. When we install the
  138. # patch into the System heap, we install everything from the first routine
  139. # in INIT.a.o to the end of the resource. This means that everything we
  140. # want to stay resident must be AFTER INIT.a.o, and everything that is not
  141. # needed after installation should be BEFORE INIT.a.o.
  142. #------------------------------------------------------------------------------
  143.  
  144. CDEVObjects        =    ∂
  145.                     'CDEV.c.o'
  146.  
  147. INITObjects        =    ∂
  148.                     'INITInstall.a.o' ∂
  149.                     'ShowINIT.a.o' ∂
  150.                     'INIT.a.o' ∂
  151.                     'INIT.c.o' ∂
  152.                     'SAGlobals.c.o'
  153.  
  154.  
  155. #------------------------------------------------------------------------------
  156. # These help define the libraries that we want to link with. {CLibs} holds
  157. # the libraries we want to link with under MPW 3.0 or MPW 3.1. Under MPW 3.2
  158. # and later, “CInterface.o” and “CRuntime.o” are merged with “Interface.o” and
  159. # “Runtime.o”. So, under 3.2 and later, we link with the files in {CLibs32}
  160. # instead. Note that we use the library routines defined in PLStringFuncs.h,
  161. # which requires us to include “PasLib.o” in our {CLibs} and {CLibs32}
  162. # variables.
  163. #------------------------------------------------------------------------------
  164.  
  165. PLibs            =    ∂
  166.                     "{Libraries}Runtime.o" ∂
  167.                     "{UtilityFolder}"GestaltGlue.a.o ∂
  168.                     "{Libraries}Interface.o" ∂
  169.                     "{PLibraries}PasLib.o"
  170.  
  171. CLibs            =    ∂
  172.                     "{CLibraries}CRuntime.o" ∂
  173.                     "{CLibraries}CInterface.o" ∂
  174.                     "{UtilityFolder}"GestaltGlue.a.o ∂
  175.                     "{Libraries}Interface.o" ∂
  176.                     "{PLibraries}PasLib.o"
  177.  
  178. CLibs32            =    ∂
  179.                     "{Libraries}Runtime.o" ∂
  180.                     "{Libraries}Interface.o" ∂
  181.                     "{PLibraries}PasLib.o"
  182.  
  183.  
  184. #------------------------------------------------------------------------------
  185. # Dependencies for the individual components. These will invoke the
  186. # default build rules listed in Chapter 9 of the MPW 3.0 manual.
  187. #
  188. # The below dependency says that all of the object listed in {CDEVObjects} and
  189. # {INITObjects} are dependent on this makefile and “Common.h”.
  190. #------------------------------------------------------------------------------
  191.  
  192. {CDEVObjects} {INITObjects}    ƒ    {AppName}.make Common.h
  193.  
  194.  
  195. #------------------------------------------------------------------------------
  196. # Build rule that links our application together. If any of our objects 
  197. # changes, or this makefile changes, then we relink.  The dummy prerequisite
  198. # ShellForce must come before any other prerequisites for {AppName}.
  199. #------------------------------------------------------------------------------
  200.  
  201. {AppName}            ƒƒ {CDEVObjects}
  202.     Echo "    Linking:    CDEV"
  203.     Link {CDEVLinkOptions} -o {Targ} {CDEVObjects} {CLibs32}
  204.     SetFile {Targ} -t cdev -c {Signature} -a B
  205.  
  206. {AppName}            ƒƒ {INITObjects}
  207.     Echo "    Linking:    INIT"
  208.     Link {INITLinkOptions} -o {Targ} {INITObjects} {CLibs32}
  209.     SetFile {Targ} -t cdev -c {Signature} -a B
  210.  
  211.  
  212. #------------------------------------------------------------------------------
  213. # Build rule that creates our resources and adds them to the application
  214. #------------------------------------------------------------------------------
  215.  
  216. {AppName}        ƒƒ    {AppName}.make ∂
  217.                     'CDEV.rsrc'
  218.     Echo "    Merging:    CDEV.rsrc"
  219.     Echo 'include "CDEV.rsrc";' | Rez {RezOptions} -o {AppName}
  220.  
  221. #------------------------------------------------------------------------------
  222. # Build rule that copies our CDEV to the System Folder when it's all built.
  223. #------------------------------------------------------------------------------
  224.  
  225. #{AppName}        ƒƒ    {CDEVObjects} {INITObjects} 'CDEV.rsrc' {AppName}.make
  226. #    Duplicate -y {AppName} "{SystemFolder}"
  227.